#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>


int main() {
    int n,m=0;
    scanf("%d\n", &n);//row
    int** arr = (int**)malloc(n*sizeof(int*));
    scanf("%d\n", &m);//col
    for (int i = 0; i < n;i++)
    {
        arr[i] = (int*)malloc(m * sizeof(int));
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            scanf("%d ", &arr[i][j]);
        }
    }

    for (int i = 1; i < n; i++)
    {
        for (int j = i - 1; j >= 0; j--)
        {
            if (arr[i][j] != 0)
            {
                printf("NO\n");
                return 0;
            }
        }
    }
    printf("YES\n");
    return 0;
}